package com.freecloud.whispered.system.repository;

import com.freecloud.framework.repository.BaseDao;
import com.freecloud.whispered.system.entity.SysConfigEntity;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

/**
 * 系统配置信息
 * 
 * @author maomao
 * @email 138383877@qq.com
 */
public interface SysConfigDao extends BaseDao<SysConfigEntity,Long> {
	
	/**
	 * 根据key，查询value
	 */
	@Query(value = "select a.value from SysConfigEntity a where a.key = :key")
	String queryByKey(@Param("key") String key);
	
	/**
	 * 根据key，更新value
	 */
	@Query(value = "update sys_config set `value` = :value where `key` = :key" ,nativeQuery = true)
	int updateValueByKey(@Param("key") String key,@Param("value") String value);

	/**
	 * 根据key,获取对象
	 * @param key
	 * @return
	 */
	@Query(value = "from SysConfigEntity a where  a.key = :key")
	SysConfigEntity queryObjectByKey(@Param("key") String key);
}
